package com.deer.wms.base.system.web.zhBusiness.electricBox;

import com.deer.wms.base.system.dao.zh.electricBox.record.ElectricBoxRecordLogMapper;
import com.deer.wms.base.system.model.record.ElectricBoxRecordLog;
import com.deer.wms.base.system.model.zh.ElectricBoxDetail;
import com.deer.wms.common.core.controller.BaseController;
import com.deer.wms.common.core.domain.AjaxResult;
import com.deer.wms.common.core.page.TableDataInfo;
import com.deer.wms.common.utils.poi.ExcelUtil;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/electricBoxLog")
public class ElectricBoxLogController extends BaseController {
    @Autowired
    ElectricBoxRecordLogMapper electricBoxRecordLogMapper;
    String prefix = "electricbox/record";

    @RequestMapping("/electricboxLog")
    public String View(){
        return prefix+"/electricboxLog";
    }
    @PostMapping("list")
    @ResponseBody
    public TableDataInfo list(ElectricBoxRecordLog e){
        startPage();
        List<ElectricBoxRecordLog> all = electricBoxRecordLogMapper.selectlog(e);
        return getDataTable(all);
    }
    @RequestMapping("/detail")
    @ResponseBody
    public String ViewLog(Model model, Integer id){
        System.out.println(id);
        return prefix+"/detail";
    }

    /**
     * 导出列表
     */

    @PostMapping("/export")
    @ResponseBody// <!--//导出全部 功能会造成内存溢出，不要使用-->
    public AjaxResult export() {
        List<ElectricBoxRecordLog> electricBoxRecordLogs = electricBoxRecordLogMapper.selectAll();
        //System.out.println(all);
        ExcelUtil<ElectricBoxRecordLog> util = new ExcelUtil<ElectricBoxRecordLog>(ElectricBoxRecordLog.class);
        return util.exportExcel(electricBoxRecordLogs, "电子箱单明细");
    }
}
